/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.ua.tester;

import edu.ua.node.ContentNode;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;

import java.util.logging.Level;
import java.util.logging.Logger;
import org.xml.sax.helpers.AttributesImpl;
import ua.edu.sax.DataWriter;
import ua.edu.sax.XMLWriter;
import ua.edu.xi.Fortran2XMI;

/**
 *
 * @author ananthaamornphong
 */
public class Tester {
    
    public void generate(ContentNode contentNode){
         try {
            String fileName = "/Users/ananthaamornphong/test-1.xmi";
             AttributesImpl attributes = new AttributesImpl();
             String documentName = "";
            
            BufferedWriter writer = new BufferedWriter(new FileWriter(fileName));
            
            DataWriter xmlWriter = new DataWriter(writer);
	
            xmlWriter.setIndentStep(2);

            xmlWriter.startDocument();
            Fortran2XMI fortran2xmi = new Fortran2XMI(xmlWriter);
            
            
            
            // create an XMI header
	attributes.clear();
	attributes.addAttribute("", "xmi.version", "", "", "1.1");
	attributes.addAttribute("", "xmlns:UML", "", "", "org.omg/standards/UML");

	xmlWriter.startElement("", "XMI", "", attributes);

	// create the XMI header in the XML file
	fortran2xmi.serializeHeader(documentName);	
        
        //ContentNode contentNode = new ContentNode();

	// serialize the UML model into the XML file
	fortran2xmi.serialzeNode(contentNode);

       	xmlWriter.endElement("XMI");
    
	xmlWriter.endDocument();

            
        } catch (Exception ex) {
           ex.printStackTrace();
        }
    }
    public static void mainX(String[] args){
        try {
            String fileName = "";
             AttributesImpl attributes = new AttributesImpl();
             String documentName = "";
            
            BufferedWriter writer = new BufferedWriter(new FileWriter(fileName));
            
            DataWriter xmlWriter = new DataWriter(writer);
	
            xmlWriter.setIndentStep(2);

            xmlWriter.startDocument();
            Fortran2XMI fortran2xmi = new Fortran2XMI(xmlWriter);
            
            
            
            // create an XMI header
	attributes.clear();
	attributes.addAttribute("", "xmi.version", "", "", "1.1");
	attributes.addAttribute("", "xmlns:UML", "", "", "org.omg/standards/UML");

	xmlWriter.startElement("", "XMI", "", attributes);

	// create the XMI header in the XML file
	fortran2xmi.serializeHeader(documentName);	
        
        ContentNode contentNode = new ContentNode();

	// serialize the UML model into the XML file
	fortran2xmi.serialzeNode(contentNode);

       	xmlWriter.endElement("XMI");
    
	xmlWriter.endDocument();

            
        } catch (Exception ex) {
           ex.printStackTrace();
        }
        
    }
}
